Training sparse networks with discrete weight values

ABSTRACT

Some embodiments provide a method for training a machine-trained (MT) network. The method propagates multiple inputs through the MT network to generate an output for each of the inputs. each of the inputs is associated with an expected output, the MT network uses multiple network parameters to process the inputs, and each network parameter of a set of the network parameters is defined during training as a probability distribution across a discrete set of possible values for the network parameter. The method calculates a value of a loss function for the MT network that includes (i) a first term that measures network error based on the expected outputs compared to the generated outputs and (ii) a second term that penalizes divergence of the probability distribution for each network parameter in the set of network parameters from a predefined probability distribution for the network parameter.

BACKGROUND

Machine learning automates the creation, based on historical data, of models that can then be used to make predictions. A class of models called deep neural networks (or DNNs) has become popular over the last few years, and there is now a menagerie of types of DNNs. Some examples of DNN's include feed-forward, convolutional, recurrent, long-short term memory (LSTM), and Neural Turing Machines (NTM).

Neural networks typically involve many (e.g., thousands, millions, or even potentially billions) of weights that are calculated during training and then used when the neural network is embedded into a device. These weights are generally floating-point values (e.g., 32-bit values), such that in total they occupy a large amount of memory. More recently, techniques have been introduced to solve this issue in part by creating very sparse networks (i.e., with most weight values set to zero), as this can reduce the amount of memory occupied by these networks. However, these techniques are still applied to floating point networks, such that each non-zero weight uses a large number of bits.

BRIEF SUMMARY

Some embodiments of the invention train the parameters of a machine-trained (MT) network using techniques designed to maximize the number of parameters that are assigned a value of zero, with each of the parameters having a discrete set of possible values (including zero) prior to training. In some embodiments, the network is a multi-layer network that includes a layer of one or more input nodes, a layer of one or more output nodes, and one or more layers of hidden (interior) nodes. Each node produces an output value based on one or more input values. Specifically, each hidden node and output node, in some embodiments, bases its output value on a set of input values (e.g., the output values of a set of other nodes, such as some or all of the nodes of the previous layer). To compute this output value, some or all of these nodes use a set of parameters (also called weight values) to linearly combine the input values of the node (and may also follow this by applying a non-linear function to the linear combination).

In some embodiments, these weights are each defined during training as a probability distribution across a set of possible values for the weight. To train the weights, a training system of some embodiments propagate numerous inputs, for which expected outputs (ground truth outputs) are known, through the network in order to generate outputs. The training system then calculates the value of a loss function for the network and backpropagates the loss function to modify the probability distributions of the weight values.

This loss function, in some embodiments, includes (i) a first term that measures the network error based on a comparison of the expected outputs to the actual outputs generated by the network and (ii) a second term that penalizes divergence of the probability distribution for each weight from a predefined probability distribution for the weight. In different embodiments, the weights may all have the same predefined probability distribution or may have different predefined probability distributions. For instance, in some embodiments, the predefined probability distribution is the same for all weights in a layer of nodes but may vary between layers.

As mentioned, each weight is assigned a discrete set of possible values, and in some embodiments the probability distribution for each weight is distributed among the possible values for the weight as a categorical distribution (i.e., the sum of all of the probabilities adds to exactly 1). The discrete set of possible values differs between different embodiments. Some embodiments use ternary weight values of zero, a non-zero value, and a negative of the nonzero value (e.g., the set {0, 1, −1}). Other embodiments use other sets of possible values, such as zero along with powers of two multiplied by a constant value. In general, the discrete set of possible weight values will include the value zero, as one goal of some embodiments is to increase the number of weight values that equal zero after training is complete.

In order to achieve this goal, the predefined probability distributions for the weights includes a large probability (greater than 0.5, and in many cases close to 1) that the value is zero in some embodiments. As a result, the second term in the loss function described above, that measures divergence from the predefined probability distributions, increases as the probability distributions for the weights includes greater probabilities for the non-zero values. On the other hand, because having all weights set to zero would result in a network that does not provide meaningful outputs, some of the weights will end up with higher probabilities for non-zero values so as to lower the first term in the loss function that measures error in the network's output.

The preceding Summary is intended to serve as a brief introduction to some embodiments of the invention. It is not meant to be an introduction or overview of all inventive subject matter disclosed in this document. The Detailed Description that follows and the Drawings that are referred to in the Detailed Description will further describe the embodiments described in the Summary as well as other embodiments. Accordingly, to understand all the embodiments described by this document, a full review of the Summary, Detailed Description and the Drawings is needed. Moreover, the claimed subject matters are not to be limited by the illustrative details in the Summary, Detailed Description and the Drawings, but rather are to be defined by the appended claims, because the claimed subject matters can be embodied in other specific forms without departing from the spirit of the subject matters.

BRIEF DESCRIPTION OF THE DRAWINGS

The novel features of the invention are set forth in the appended claims. However, for purpose of explanation, several embodiments of the invention are set forth in the following figures.

FIG. 1 illustrates an example of a multi-layer machine-trained network of some embodiments.

FIGS. 2 and 3 illustrate two different possible weight value spectrums, with a possible predefined probability distribution for each spectrum.

FIG. 4 conceptually illustrates a training system of some embodiments that balances network output error against sparsity of non-zero weight values in the loss function.

FIG. 5 conceptually illustrates a process of some embodiments for training a multi-layer machine-trained network.

FIG. 6 conceptually illustrates a process of some embodiments for computing the output value of a node within a machine-trained network during the training process.

FIG. 7 conceptually illustrates the architecture of a node during training.

FIG. 8 illustrates an example of the architecture of a mobile computing device that stores neural network processing instructions.

FIG. 9 conceptually illustrates an electronic system with which some embodiments of the invention are implemented.

DETAILED DESCRIPTION

Some embodiments of the invention train the parameters of a machine-trained (MT) network using techniques designed to maximize the number of parameters that are assigned a value of zero, with each of the parameters having a discrete set of possible values (including zero) prior to training. In some embodiments, the network is a multi-layer network that includes a layer of one or more input nodes, a layer of one or more output nodes, and one or more layers of hidden (interior) nodes. Each node produces an output value based on one or more input values. Specifically, each hidden node and output node, in some embodiments, bases its output value on a set of input values (e.g., the output values of a set of other nodes, such as some or all of the nodes of the previous layer). To compute this output value, some or all of these nodes use a set of parameters (also called weight values) to linearly combine the input values of the node (and may also follow this by applying a non-linear function to the linear combination).

In some embodiments, these weights are each defined during training as a probability distribution across a set of possible values for the weight. To train the weights, a training system of some embodiments propagate numerous inputs, for which expected outputs (ground truth outputs) are known, through the network in order to generate outputs. The training system then calculates the value of a loss function for the network and backpropagates the loss function to modify the probability distributions of the weight values.

This loss function, in some embodiments, includes (i) a first term that measures the network error based on a comparison of the expected outputs to the actual outputs generated by the network and (ii) a second term that penalizes divergence of the probability distribution for each weight from a predefined probability distribution for the weight. In different embodiments, the weights may all have the same predefined probability distribution or may have different predefined probability distributions. For instance, in some embodiments, the predefined probability distribution is the same for all weights in a layer of nodes, but may vary between layers.

As mentioned, each weight is assigned a discrete set of possible values, and in some embodiments the probability distribution for each weight is distributed among the possible values for the weight as a categorical distribution (i.e., the sum of all of the probabilities adds to exactly 1). The discrete set of possible values differs between different embodiments. Some embodiments use ternary weight values of zero, a non-zero value, and a negative of the nonzero value (e.g., the set {0, 1, −1}). Other embodiments use other sets of possible values, such as zero along with powers of two multiplied by a constant value. In general, the discrete set of possible weight values will include the value zero, as one goal of some embodiments is to increase the number of weight values that equal zero after training is complete.

In order to achieve this goal, the predefined probability distributions for the weights includes a large probability (greater than 0.5, and in many cases close to 1) that the value is zero in some embodiments. As a result, the second term in the loss function described above, that measures divergence from the predefined probability distributions, increases as the probability distributions for the weights includes greater probabilities for the non-zero values. On the other hand, because having all weights set to zero would result in a network that does not provide meaningful outputs, some of the weights will end up with higher probabilities for non-zero values so as to lower the first term in the loss function that measures error in the network's output.

The above description introduces the network training process of some embodiments for training sparse networks using discrete weight values. Several more detailed embodiments are described below. First, Section I describes the use and training of machine-trained networks generally. Next, Section II describes the mathematical basis for using Variational Bayes Inference for quantized weight values, while Section III describes the network training process in detail. Section IV then describes the incorporation of a machine-trained network into a device. Finally, Section V describes an electronic system with which some embodiments of the invention are implemented.

I. Neural Networks

FIG. 1 illustrates an example of a multi-layer machine-trained network of some embodiments. This figure illustrates a feed-forward neural network 100 that has multiple layers of processing nodes 102 (also called neurons). In all but the first (input) and last (output) layer, each node 102 receives two or more outputs of nodes from earlier processing node layers and provides its output to one or more nodes in subsequent layers. The output of the node (or nodes) in the last layer represents the output of the network 100. In different embodiments, the output of the network 100 is a number in a range of values (e.g., 0 to 1), a vector representing a point in an N-dimensional space (e.g., a 128-dimensional vector), or a value representing one of a predefined set of categories (e.g., for a network that classifies each input into one of eight possible outputs, the output could be a three-bit value). In this example, the neural network 100 only has one output node. Other neural networks of other embodiments have several output nodes that provide more than one output value. In addition, the neural networks of other embodiments may be types of networks other than feed forward networks (e.g., recurrent networks, etc.).

As shown in FIG. 1 , each node in the neural network 100 has a linear component 110 and a nonlinear component 115. The linear component 110 of each hidden or output node in this example computes a dot product of a vector of weight coefficients and a vector of output values of prior nodes, plus an offset. In other words, a hidden or output node's linear operator computes a weighted sum of its inputs (which are outputs of the previous stage node that the linear operator receives) plus an offset. Similarly, the linear component 110 of each input node of some embodiments computes a dot product of a vector of weight coefficients and a vector of input values, plus an offset. In other embodiments, each input node receives a single input and passes that input as its output. As described below, in some embodiments, rather than use defined weight values, during training of the neural network the weight values are treated as probability distributions, with the linear component computing an output mean and variance based on these probability distributions. Each node's nonlinear component 115 computes a function based on the output of the node's linear component 110. This function is commonly referred to as the activation function.

The notation of FIG. 1 can be described as follows. Consider a neural network with L hidden layers (i.e., L layers that are not the input layer or the output layer). The variable l can be any of the hidden layers (i.e., l∈{1, . . . , L−1} index the hidden layers of the network, with l=0 representing the input layer and l=L representing the output layer). The variable z_(i) ^((i+1)) represents the output of the linear component of a hidden node i in layer l+1. As indicated by the following Equation (A), the variable z_(i) ^((i+1)) is computed as the dot product of a vector of weight values W_(i) ^((i+1)) and a vector of outputs y^((l)) from layer l multiplied by a constant value c_(i), and offset by a bias value b_(i):

$\begin{matrix} {z_{i}^{({l + 1})} = {{{\left( {W_{i}^{({l + 1})} \cdot y^{(l)}} \right) \star c_{i}} + b_{i}^{({l + 1})}} = {{\sum\limits_{k = 1}^{n}{\left( {w_{ik}^{({l + 1})} \star y_{k}^{(l)}} \right) \star c_{i}}} + {b_{i}^{({l + 1})}.}}}} & (A) \end{matrix}$

The constant value c_(i) is a value to which all the weight values are normalized. In some embodiments, the constant value c_(i) is 1. The symbol * is an element-wise product, while the symbol · is the dot product. The weight coefficients W^((l)) are parameters that are adjusted during the network's training in order to configure the network to solve a particular problem (e.g., object or face recognition in images, voice analysis in audio, depth analysis in images, etc.)

The output y^((l+1)) of the nonlinear component 115 of a node in layer l+1 is a function of the node's linear component, and can be expressed as by Equation (B) below: y _(i) ^((l+1))=ƒ(Z _(i) ^((l+1))  (B) In this equation, ƒ is the nonlinear activation function for node i. Examples of such activation functions include a sigmoid function 120 (ƒ(x)=1/(1+e^(−x))), a tanh function 125, a ReLU (rectified linear unit) function 130 or a leaky ReLU function 135, as shown.

Traditionally, the sigmoid function and the tanh function have been the activation functions of choice. More recently, the ReLU function (ƒ(x)=max(0, x)) has been proposed for the activation function in order to make it easier to compute the activation function. See Nair, Vinod and Hinton, Geoffrey E., “Rectified linear units improve restricted Boltzmann machines,” ICML, pp. 807-814, 2010. Even more recently, the leaky ReLU has been proposed in order to simplify the training of the processing nodes by replacing the flat section (i.e., x<0) of the ReLU function with a section that has a slight slope. See He, Kaiming, Zhang, Xiangyu, Ren, Shaoqing, and Sun, Jian, “Delving deep into rectifiers: Surpassing human-level performance on imagenet classification,” arXiv preprint arXiv:1502.01852, 2015. In some embodiments, the activation functions can be other types of functions, like cup functions and periodic functions.

Equation (B) can be expressed in the following expanded format of Equation (C):

$\begin{matrix} {y_{i}^{({l + 1})} = {{f\left( z_{i}^{({l + 1})} \right)} = {{f\left\lbrack {{\left( {\sum\limits_{k = 1}^{n}{w_{ik} \star y_{k}}} \right) \star c_{i}} + b_{i}^{({l + 1})}} \right\rbrack}.}}} & (C) \end{matrix}$ In this equation, w_(ik) are weight values associated with the inputs y_(k) of the node i in layer l+1.

In some embodiments, the neural network is a convolutional feed-forward neural network. In this case, the intermediate layers (referred to as “hidden” layers) may include convolutional layers, pooling layers, fully-connected layers, and normalization layers. The convolutional layers of some embodiments use a small kernel (e.g., 5 pixels×5 pixels) to process each tile of pixels in an image with the same set of parameters. Pooling layers combine the outputs of clusters of nodes from one layer into a single node at the next layer, as part of the process of reducing an image (which may have a large number of pixels) or other input item down to a single output (e.g., a vector output).

Before a multi-layer network can be used to solve a particular problem, the network is put through a supervised training process that adjusts the network's configurable parameters (e.g., the weight coefficients of its linear components). The training process iteratively selects different input value sets with known output value sets. For each selected input value set, the training process typically (1) forward propagates the input value set through the network's nodes to produce a computed output value set and then (2) backpropagates a gradient (rate of change) of a loss function (output error) that quantifies in a particular way the difference between the input set's known output value set and the input set's computed output value set, in order to adjust the network's configurable parameters (e.g., the weight coefficients). As mentioned, some embodiments use a loss function that balances the network accuracy against the desire for sparsity (having as many weights set to zero as possible).

II. Variational Bayes Inference for Quantized Weights

As mentioned, some embodiments train the weights of a network using techniques designed to maximize the number of parameters that are assigned a value of zero, with each of the parameters having a discrete set of possible values (including zero) prior to training. Specifically, some embodiments define each weight as a probability distribution across a set of possible values for the weight. To train the weights, numerous inputs, for which expected outputs are known, are propagated through the network in order to generate outputs. The training system then calculates the value of a loss function for the network and backpropagates the loss function to modify the probability distributions of the weight values. The loss function of some embodiments, balances the network error (based on comparing the expected outputs to the actual outputs) with a penalty for the use of non-zero weight values. This penalty term uses the divergence of the probability distributions for the weights from the predefined probability distribution in some embodiments, based on the concepts of Variational Bayes Inference (VBI).

A. Discrete Weight Spectrum

As mentioned, each weight is assigned a discrete set of possible values, and in some embodiments the probability distribution for each weight is distributed among the possible values for the weight as a categorical distribution (i.e., the sum of all of the probabilities adds to exactly 1). In some embodiments, the spectrum of possible weight values is different for each layer of the network. For any given layer, the spectrum is described as {s_(i)|i∈S}. For simplicity, the following description considers a single network layer, so as to remove the layer index.

In general, the discrete set of possible weight values will include the value zero, as one goal of some embodiments is to increase the number of weight values that equal zero after training is complete. The actual discrete spectrum of possible values differs between different embodiments. Some embodiments use ternary weight values of zero, a non-zero value, and a negative of the nonzero value (e.g., the set {0, 1, −1}). Other embodiments use other sets of possible values, such as zero along with powers of two multiplied by a constant value:

$\begin{matrix} {s_{i} = \left\{ {\begin{matrix} {0,} & {i = 0} \\ {{\alpha 2^{{❘i❘} - 1}{{sign}(i)}},} & {{i = {\pm 1}},{\pm 2},\ldots,{\pm n}} \end{matrix}.} \right.} & (D) \end{matrix}$

In the above equation, the overall scale of weights in the layer is controlled by the layer-dependent α, and the number of distinct weight values in the layer is |S|=2n+1. One advantage of such a weight spectrum is that the dot products of the inputs and weights in the eventual trained network can be implemented using shifters rather than multipliers, aside from the overall multiplication by α.

B. Categorical Distribution

As noted, some embodiments define a probability distribution over the discrete spectrum of possible weight values for each weight in a layer. This probability distribution is a categorical distribution (or multinoulli distribution), meaning that all of the probabilities are between 0 and 1 (inclusive), and the sum of all of the probabilities is exactly equal to 1. The predefined, or prior, distribution, is referred to as p and the posterior (resultant) distribution is referred to as q. For any i∈S, p_(i) is the prior probability that the weight takes on value s_(i) and q_(i) is the posterior probability that the weight takes on value s_(i).

FIGS. 2 and 3 illustrate two different possible weight value spectrums, with a possible predefined probability distribution for each spectrum. First, FIG. 2 illustrates a ternary weight spectrum with possible weight values of 0, 1, and −1 (some embodiments will use a random scaling factor α, for possible weight values of 0, α, and −α). In this example, the predefined (prior) probability distribution assigns 0.1 to each of the possible weight values 1 and −1, and assigns the remaining 0.8 to the value 0. In the case (as in this example) in which the negative and positive weight values are assigned the probability, then the equation

$p_{1} = {p_{- 1} = \frac{1 - p_{0}}{2}}$ applies. In some embodiments that use quinary or other larger spectra, other distributions may be used (e.g., all non-zero values are assigned the same probability, the probabilities fall off as the distance from zero increases, etc.

FIG. 3 illustrates a powers-of-2 weight spectrum according to Equation (D), with possible weight values of 0, 1, −1, 2, −2, 4, and −4. As indicated in this equation above, the weight value spectrum may also be scaled by a random layer-specific scaling value a in some embodiments. In this example, the predefined probability distribution assigns 0.05 to each of the six non-zero weight values (1, −1, 2, −2, 4, and −4), and assigns 0.6 to the value 0. In both of these illustrated cases, the highest probability is assigned to the value 0. As such, each weight that diverges from the value 0 (i.e., is assigned a different weight in the spectrum) is penalized in the loss function. However, as these weights can also reduce the network error, some of the weights are assigned non-zero values.

The variable x_(i) refers to the random Boolean variable that is 1 if weight value s_(i) is selected, and 0 if a different weight value in the spectrum is selected. The posterior probability of the vector x is then

$\begin{matrix} {{P\left( {x{❘q}} \right)} = {{\prod\limits_{i \in S}q_{i}^{x_{i}}} = {\exp{\left\{ {\sum\limits_{i \in S}{x_{i}\ln q_{i}}} \right\}.}}}} & (E) \end{matrix}$

Because exactly one weight value is actually selected, the sum over all of the x_(i) is 1 (Σ_(i∈S)x_(i)=1). As a result, one of the x_(i) can be eliminated. Choosing x₀ (with s₀=0), this value can be expressed in terms of the other components of the vector x:

$\begin{matrix} {x_{0} = {1 - {\sum\limits_{\underset{i \neq 0}{i \in S}}{x_{i}.}}}} & (F) \end{matrix}$ This means that the posterior distribution for x can be expressed as the following:

$\begin{matrix} {{P\left( {x{❘q}} \right)} = {\exp{\left\{ {{\sum\limits_{\underset{i \neq 0}{i \in S}}{x_{i}\ln\frac{q_{i}}{q_{0}}}} - {\ln\frac{1}{q_{0}}}} \right\}.}}} & (G) \end{matrix}$ With the dependent variable x₀ eliminated, the revised probability distribution P(x|q) is defined over the space:

$\begin{matrix} {0 \leq {\sum\limits_{\underset{i \neq 0}{i \in S}}x_{i}} \leq 1.} & (H) \end{matrix}$ Because q₀ is determined by the other q_(i), as shown by the following equation,

$\begin{matrix} {{q_{0} = {1 - {\sum\limits_{\underset{i \neq 0}{i \in S}}q_{i}}}},} & (I) \end{matrix}$ the distribution P(x|q) is fully parameterized by the subset of probability parameters {q_(i): i∈S, i≠0}. In the ternary case, this means that each weight is constrained to a 2-dimensional space (because the probabilities add up to 1, the third weight value probability can be determined based on the other two).

1. Natural Parameters

The categorical distribution shown in equation (G) is a member of the exponential family of probability distributions. In general, members of the exponential family have probability distributions that can be reparametrized using the general form P(x|q)=h(x)exp{η^(T) T(x)−A(η)}.  (J) In this expression, T(x) is referred to as the sufficient statistic, which fully summarizes the data x within the density function. Compared with equation (G), it can be seen that the sufficient statistic is equal to x itself. The natural parameters of the distribution, η_(i) (the set of values for which P(x|q), show in Equation (J), is finite) are given as

$\begin{matrix} {\left\{ {{\eta_{i} = {{\ln\frac{q_{i}}{q_{0}}:i} \in S}},{i \neq 0}} \right\}.} & (K) \end{matrix}$

The natural parameters in this reparameterization have the benefit that the valid range (for each of the η_(i)) is all of

(the real number space). This is the case due to the elimination of x₀ and q₀, without which the probabilities are restricted by the equation Σ_(i∈S)x_(i)=1. The benefit of expanding the valid range for the parameters to the entire real number space is that clipping need not be required during backpropagation. If modifying the q, during the gradient step of backpropagation, some embodiments clip these values to stay within the probability simplex of 0-1. However, the natural parameters do not require such clipping, meaning that all data can be preserved.

For notational convenience, the vector η_(i)=ln(q_(i)/q₀) can be extended to include a zero component, η₀=ln(q₀/q₀)=0. As a result,

$\begin{matrix} {{1 = {{\sum\limits_{i \in S}q_{i}} = {{q_{0}{\sum\limits_{i \in S}\frac{q_{i}}{q_{0}}}} = {q_{0}{\sum\limits_{i \in S}e^{\eta_{i}}}}}}},} & (L) \end{matrix}$ $\begin{matrix} {q_{0} = {\frac{1}{\sum\limits_{i \in S}e^{\eta_{i}}}.}} & (M) \end{matrix}$ so that q₀ is given by The original parameters of the categorical distribution (the q_(i)) can therefore be computed in terms of the natural parameters using the soft-max function

$\begin{matrix} {q_{i} = {\frac{e^{\eta_{i}}}{\sum\limits_{j \in S}e^{\eta_{j}}}.}} & (N) \end{matrix}$

A (η) is the cumulant-generating function, which is used (as shown below in the next sub-section) to define the mean, variance, and other cumulants. This function for the probability distribution shown in Equation (J) is given by

$\begin{matrix} {{A(\eta)} = {{\ln\frac{1}{q_{0}}} = {{\ln\left( {\sum\limits_{i \in S}e^{\eta_{i}}} \right)}.}}} & (O) \end{matrix}$ An advantage of treating the categorical distribution as a member of the exponential family is that the properties of such a distribution are well-known, as are the results for the mean, variance, Kullback-Leibler (KL) divergence, and other properties.

2. Cumulants

The mean, variance, and other cumulants of an exponential distribution can be computed as derivatives of the cumulant-generating function, given above by Equation (O), with respect to the natural parameters. The mean, in this case, is given by

$\begin{matrix} {{{\overset{¯}{x} \equiv {{\mathbb{E}}\left\lbrack x_{i} \right\rbrack}} = {{{\mathbb{E}}\left\lbrack {T(x)}_{i} \right\rbrack} = {\frac{\partial{A(\eta)}}{\partial\eta_{i}} = q_{i}}}},} & (P) \end{matrix}$ the covariance is given by

$\begin{matrix} {{{{Cov}\left\lbrack {x_{i},x_{j}} \right\rbrack} = {{{Cov}\left\lbrack {{T(x)}_{i},{T(x)}_{j}} \right\rbrack} = {\frac{\partial^{2}{A(\eta)}}{{\partial\eta_{i}}{\partial\eta_{j}}} = {{q_{i}\delta_{ij}} - {q_{i}q_{j}}}}}},} & (Q) \end{matrix}$ and the coskewness is given by

$\begin{matrix} \begin{matrix} {{{Coskew}\left\lbrack {x_{i},x_{j},x_{k}} \right\rbrack} = {{\mathbb{E}}\left\lbrack {\left( {x_{i} - {\overset{¯}{x}}_{i}} \right)\left( {x_{j} - {\overset{¯}{x}}_{j}} \right)\left( {x_{k} - {\overset{¯}{x}}_{k}} \right)} \right\rbrack}} \\ {= {{Coskew}\left\lbrack {{T(x)}_{i},{T(x)}_{j},{T(x)}_{k}} \right\rbrack}} \\ {= \frac{\partial^{3}{A(\eta)}}{{\partial\eta_{i}}{\partial\eta_{j}}{\partial\eta_{k}}}} \\ {= {{q_{i}\delta_{ij}\delta_{ki}} - {q_{i}q_{j}\delta_{jk}} - {q_{j}q_{k}\delta_{ki}} - {q_{k}q_{i}\delta_{ij}} - {2q_{i}q_{j}q_{k}}}} \end{matrix} & (R) \end{matrix}$

3. Weight Mean and Variance

For forward and backward propagation of data through the MT network, some embodiments require the mean and variance of the weights, not just of the natural parameters. The cumulants shown in the above subsection can be used to compute the mean and variance of each of the weights, as shown by the following:

$\begin{matrix} {{{\mu \equiv {{\mathbb{E}}\left\lbrack {\sum\limits_{i \in S}{x_{i}s_{i}}} \right\rbrack}} = {\sum\limits_{i \in S}{q_{i}s_{i}}}},} & (S) \end{matrix}$ $\begin{matrix} {{\sigma^{2} \equiv {{Var}\lbrack w\rbrack}} = {{\sum\limits_{i,{j \in S}}{s_{i}s_{j}{{Cov}\left\lbrack {x_{i},x_{j}} \right\rbrack}}} = {{{\sum\limits_{i \in S}{q_{i}s_{i}^{2}}} - \left( {\sum\limits_{i \in S}{q_{i}s_{i}}} \right)^{2}} = {{{\mathbb{E}}\left\lbrack w^{2} \right\rbrack} - {\mu^{2}.}}}}} & (T) \end{matrix}$

These summations can be restricted to i≠0, given that s₀=0. In order to avoid a loss of significance (and possibly avoid a negative result), some embodiments compute the weight variance as

$\begin{matrix} {{\sigma^{2} = {\sum\limits_{i \in S}{q_{i}\left( {s_{i} - \mu} \right)}^{2}}}.} & (U) \end{matrix}$

Some embodiments perform forward propagation using the weight means and variances, as described in more detail below, but directly adjust the natural parameters (which correspond to adjustments to the weight means and variances as described above). As such, the derivatives of the weight mean and variance with respect to the natural parameters are required for backpropagation:

$\begin{matrix} \begin{matrix} {\frac{\partial\mu}{\partial\eta_{i}} = {\sum\limits_{j \in S}{s_{j}\frac{\partial^{2}{A(\eta)}}{{\partial\eta_{i}}{\partial\eta_{j}}}}}} \\ {= {\sum\limits_{j \in S}{s_{j}{{Cov}\left\lbrack {x_{i},x_{j}} \right\rbrack}}}} \\ {{= {q_{i}\left( {s_{i} - \mu} \right)}},} \\ {\frac{\partial\sigma^{2}}{\partial\eta_{i}} = {\sum\limits_{j,{k \in S}}{s_{j}s_{k}\frac{\partial^{3}{A(\eta)}}{{\partial\eta_{i}}{\partial\eta_{j}}{\partial\eta_{k}}}}}} \\ {= {\sum\limits_{j,{k \in S}}{s_{j}s_{k}{{Coskew}\left\lbrack {x_{i},x_{j},x_{k}} \right\rbrack}}}} \end{matrix} & (V) \end{matrix}$ $\begin{matrix} {= {{q_{i}\left\lbrack {\left( {s_{i} - \mu} \right)^{2} - \sigma^{2}} \right\rbrack}.}} & (W) \end{matrix}$

Some embodiments also vary the spectrum of possible weight values and/or the scaling factor α (in addition to the probability distribution for the weights and/or natural parameters) during training in order to minimize the loss function. For this purpose, the derivatives of the mean and variance with respect to the weight spectrum values are as follows:

$\begin{matrix} {\frac{\partial\mu}{\partial s_{i}} = q_{i}} & (X) \end{matrix}$ $\begin{matrix} {\frac{\partial\sigma^{2}}{\partial s_{i}} = {2{{q_{i}\left( {s_{i} - \mu} \right)}.}}} & (Y) \end{matrix}$ The derivatives of the mean and variance with respect to the scaling factor are:

$\begin{matrix} {{\frac{\partial\mu}{\partial\alpha} = \frac{\mu}{\alpha}},} & (Z) \end{matrix}$ $\begin{matrix} {\frac{\partial\sigma^{2}}{\partial\alpha} = {\frac{2\sigma^{2}}{\alpha}.}} & ({AA}) \end{matrix}$

4. Kullback-Leibler Divergence

Kullback-Leibler (KL) divergence is a measure of how much one probability distribution diverges from a second (expected) probability distribution and is also referred to as the relative entropy. Some embodiments use the KL divergence within the loss function as a constraint that forces sparsity (i.e., having more of the weight values set to 0) in the network. In this case, the KL divergence is used to compute the divergence of the prior distribution (p) from the posterior distribution (q). This divergence is calculated as follows:

$\begin{matrix} \begin{matrix} \left. {{{{D_{KL}\left( {q{p}} \right)} = {D_{KL}\left( \eta \right.}}}\eta^{\prime}} \right) \\ {= {{\left( {\eta - \eta^{\prime}} \right)^{T}{{\mathbb{E}}\left\lbrack {T(x)} \right\rbrack}} - {A(\eta)} + {A\left( \eta^{\prime} \right)}}} \\ {= {{\sum\limits_{\underset{i \neq 0}{i \in S}}{\left( {\eta_{i} - {\eta_{i}}^{\prime}} \right)q_{i}}} - {A(\eta)} + {{A\left( \eta^{\prime} \right)}.}}} \end{matrix} & ({BB}) \end{matrix}$ In Equation (BB), {η_(i)′=ln(p_(i)/p₀):i∈S}, are the natural parameters for the prior distribution.

For backpropagation of the loss function, the derivatives of the KL divergence with respect to the natural parameters of the prior and posterior distributions are calculated as follows:

$\begin{matrix} {{\frac{\partial{D_{KL}\left( {q{p}} \right)}}{\partial\eta_{i}} = {q_{i}\left\lbrack {\left( {\eta_{i} - \eta_{i}^{\prime}} \right)\left( {\eta - \eta^{\prime}} \right)^{T}q} \right\rbrack}},} & ({CC}) \end{matrix}$ $\begin{matrix} {\frac{\partial{D_{KL}\left( {q{p}} \right)}}{\partial\eta_{i}} = {p_{i} - {q_{i}.}}} & ({DD}) \end{matrix}$

C. Variational Bayes Inference

In some embodiments, VBI is used to maximize the variational lower bound on the “marginal likelihood of the data”. This function is given by

(q)=L _(D)(q)−D _(KL)(q∥p).  (EE) In this equation (EE), L_(D)(q) is the log-likelihood of the data, the negative of which provides a measure of the network error. This log-likelihood is given by the equation

$\begin{matrix} {{L_{D}(q)} = {\sum\limits_{n = 1}^{N}{{{\mathbb{E}}\left\lbrack {\ln{p\left( {y_{n}{❘{x_{n},w}}} \right)}} \right\rbrack}.}}} & ({FF}) \end{matrix}$

In Equation (FF), the sum is over all items n in the training batch, with item n having input x_(n) and ground truth y_(n). The expectation is over the posterior probability distribution q for all the weights. Because the goal is to minimize (rather than maximize) a loss function, −

(q) is used as the loss function l: l=−

(q)=L _(D)(q)+D _(KL)(q∥p).  (GG) Thus, in addition to the usual negative log-likelihood term, the loss function includes a regularization term (the KL divergence) that penalizes the divergence of the prior probability distribution from the posterior probability distribution. In some embodiments, the KL term is phased in through training, so as to allow the network can achieve better accuracy initially and not be as constrained by the prior distribution.

The KL divergence term provides the loss function with a principled approach to regularization (there is no human-tuned coefficient in the regularization term), which ties the process into the minimum description length principle. The minimum description length principle, generally, holds that the best solution is that which permits the best compression of data. In this case, the goal is to minimize the overall use of error bits (represented by the negative log-likelihood) and model fit bits (represented by the KL divergence).

Some embodiments use additional terms in the loss function as well. For instance, some embodiments add the total entropy of all of the weights. At the end of training, this entropy should be zero, as all of the weights will have exactly one state (i.e., for any particular weight, the probability of one of the possible weight values will be 1 and the probability of all the other possible weight values will be 0). Some embodiments use an augmented Lagrangian term to enforce this as a global constraint (i.e., requiring the entropy of the overall posterior probability distributions to be zero). An example of such a term is

${\mathcal{L} = {{\mu E} + {\frac{c}{2}E^{2}}}},$ where μ is a Lagrange multiplier and E represents the total entropy. As described for stochastic quantization techniques in U.S. patent application Ser. No. 15/815,222, now issued as U.S. Pat. No. 11,113,603, which is incorporated herein by reference, such a term can be increased throughout training to slowly force the weights towards an optimal value. III. Network Training Process

FIG. 4 conceptually illustrates a training system 400 of some embodiments that balances network output error against sparsity of non-zero weight values in the loss function. The training system 400 uses a set of discrete weight value candidates (which may be the same for all nodes in a network being trained, different for each layer of nodes, or different for each node in the network) to define a prior probability distribution for each weight, which is then used in the computation of the loss function. The resulting weight values, which in the optimal case are primarily the value 0, are used for the multi-layer network when embedded in a device to perform a particular function.

As shown, the system 400 includes an input generator 405, an error calculator 410, an error propagator 415, and a weight modifier 425. In some embodiments, all of these modules execute on a single device, such as a server, desktop or laptop computer, a mobile device (e.g., a smartphone, tablet, etc.), a virtual machine, etc. In other embodiments, these modules may execute across multiple interconnected devices (or virtual machines), or separate instances may execute on multiple devices (or virtual machines) for additional computing power. In some embodiments, at least some of the operations are executed by one or more graphics processing units (GPUs) of such a computing device (or devices).

FIG. 5 conceptually illustrates a process 500 of some embodiments for training a multi-layer machine-trained network. This process 500 will be described in part by reference to the training system 400. As shown, the process begins by receiving (at 505) a multi-layer network for training, with discrete sets of possible weight values and predefined probability distributions for each weight in the network. The process 500 also receives (at 510) a set of inputs and an expected output for each of the inputs. Depending on the purpose of the network and the type of inputs, these expected outputs may be values in multi-dimensional space, classifications (e.g., for images), etc.

The network 430 of some embodiments is a multi-layer machine-trained network (e.g., a feed-forward neural network), such as that shown in FIG. 1 . This network 430 includes multiple layers of nodes, including a layer of input nodes, at least one layer of hidden nodes, and a layer of output nodes. Each of at least a subset of the hidden nodes and output nodes includes a linear component (that uses the weight values 435) and a non-linear activation function. The network receives an input and computes a corresponding output.

The weight values are used to parameterize the network and are trained by the system 400 for the network to perform a particular task. As discussed above, in some embodiments the weights are represented by categorical probability distributions between a discrete set of possible weight values (e.g., 0, 1, −1), and the weights are assigned initial predefined probability distributions, which are modified during the course of training. In addition, some embodiments also store the natural parameters of the distribution with the weight values.

For the inputs, some embodiments perform training with a large number of different inputs, as this can help train the weight values for an average input. Each input in an input set may be an image, a voice snippet, etc. that is to be propagated through the network, depending on the specific purpose for which the network is being trained. For example, if a network is being trained to identify faces, the set of inputs will include numerous images of several different people's faces, probably including various types of edge cases (e.g., images where the face is distorted, where objects partially appear in front of the face, etc.). Each input also has a corresponding expected (ground truth) output that is what the network should generate as its output when presented with that input.

The input generator 405 selects a set of inputs (and corresponding expected outputs) from the sets of inputs and outputs 440. In addition, in some embodiments, the input generator 405 breaks up the inputs into constituent values to be fed into the input layer of the network 430. For instance, for a network being trained to recognize objects in images or to differentiate faces, the input generator might simply divide the pixels into several sections, or might perform computations based on the pixel values and feed these to the input layer (e.g., the percentage of red pixels in the image, the average red value of each pixel, or other statistics). That is, based on the input (e.g., an image), the input generator 405 might perform a set of computations in order to generate the inputs for the input layer of the network 430.

Next, the network 430 processes (at 515) the set of inputs through the network to obtain computed outputs (i.e., outputs predicted according to the current state of the network 430, using the current weight spectra and probability distributions). Each input propagates through the processing nodes of the network 430, with each layer of nodes receiving their one or more inputs and generating an output to pass to the next layer of nodes. In the final output layer, one or more nodes receives the outputs from the previous layer and generates the outputs of the network. In some embodiments, this processing entails, for each node, the linear component first computing a weighted sum of its input values, and then the non-linear activation function computing an output based on this weighted sum.

Some embodiments compute the linear component by randomly sampling from the probability distributions from the weights. Rather than directly sampling from the probability distribution for each weight for each of the inputs, some embodiments calculate the mean and variance for each weight (using, e.g., Equations (S) and (U) above) and use these along with the node input values to compute an output mean and variance for each node. Once the output mean and variance are calculated, the network 430 randomly samples from the output distribution (e.g., assuming a normal distribution) in some embodiments. This process is described in greater detail below and has the benefit of using a single mean and variance for each weight value rather than randomly sampling each weight value for each different network input during a training iteration (thereby providing an efficiency benefit to the processor performing the calculations). Other embodiments propagate the mean and variance through the network rather than randomly sampling, which is also described in detail below.

The process 500 then computes (at 520) the error for the input set based on a comparison of the expected outputs to the computed outputs. In some embodiments, the error calculator 410 computes the error for each individual input as the network 430 generates its output, while in other embodiments the error is computed after all of the outputs are generated (e.g., in cases for which the error is calculated based on comparison of different outputs to each other as well). The error calculator 410 of some embodiments receives both the predicted output from the input generator 405 and the output of the network 430 and uses a loss function that quantifies the difference between the predicted output and the actual output for each input. Some embodiments compute this as a simple difference, or absolute value of the difference, between the two values; other embodiments compute the square of the differences, or other such measure. In addition, some embodiments sum or average the loss function value for each input in a set of inputs.

The process 500 (e.g., the error calculator 410) also adds (at 525) the divergence of the current (posterior) probability distribution from the predefined (prior) probability distribution to the error, as a constraint on the weight parameters (i.e., to constrain the number of non-zero weights). As described in the previous section, some embodiments use the KL divergence for this term of the loss function. This calculated loss function value (i.e., the value computed by equation GG) is passed to the error propagator 315 in some embodiments.

With the loss function calculated, the process 500 (e.g., the error propagator 415) backpropagates (at 530) the error and divergence to determine the rate of change of the loss function with respect to the change of the probability distribution. Specifically, some embodiments first determine the derivative of the negative log-likelihood loss (i.e., the L_(D)(q) term in Equation (GG)), then use the chain rule to compute the derivative o the negative log-likelihood loss term with respect to the natural parameters and the weight spectrum values for each weight. The derivative of the KL divergence with respect to the posterior and prior natural parameters is then added to the derivative of the KL divergence. Additional details of the negative log-likelihood derivatives are provided below.

Next, the process 500 (e.g., the parameter modifier 425) adjusts the probability distributions based on the relative rates of change identified by the error propagator. The error propagator 415 provides, for each natural parameter η_(i) of the posterior distribution for each weight value, the partial derivative of the total loss function with respect to that parameter. These partial derivatives are used to update the natural parameters by moving the parameters in the direction opposite the gradient (to attempt to reduce the loss function value) by a particular amount, with a larger partial derivative for a particular parameter resulting in a greater change to the parameter. The parameter modifier 425 uses a training rate factor from the training parameters 450 to determine how much to adjust the parameters based on the instantaneous gradient components. In some embodiments, the natural parameter adjustments correspond to adjustments to the probability distribution among the spectrum of possible weight values for the weight according to, e.g., Equation (N).

Some embodiments also adjust the weight spectrum values for each layer using the computed gradients. Furthermore, some embodiments adjust the prior distribution natural parameters for each layer, while other embodiments keep the prior distribution constant throughout the training process.

After updating the weights, the process 500 determines (at 540) whether to perform more training. Some embodiments use a minimization process to determine when to stop training the network. In some embodiments, the system 400 only stops training the network once (i) a large enough percentage of the weight values have been set to zero, (ii) a large enough percentage of the probability distributions have collapsed so that all of the weights have definite assignments to one of their possible weight values, and (iii) the probability distributions have changed by less than a threshold for a particular number of training iterations. Other embodiments may have other conditions for completing training. In some embodiments, the input generator 405 determines whether to perform more training, while in other embodiments, a different module (e.g., a module not shown in FIG. 4 ) makes this determination.

If additional training is required, the process returns to 510 to perform another iteration of training with another set of inputs. Some embodiments use the same set of inputs for each training iteration, while other embodiments use different inputs each iteration. If training is complete, the process assigns (at 545) the weight values for the trained network (i.e., converts the probability distributions for the weights to actual weight values), and stores these values for enabling the network to perform its designated purpose. The process 500 then ends.

A. Randomly Sampling Outputs

As mentioned, during forward propagation of the inputs through the network some embodiments do not directly choose a weight value for each weight, but instead use the means and variances of the categorical distribution for the weight in order to compute the mean and variance for the output of the linear component of a node, then randomly sample this output.

FIG. 6 conceptually illustrates a process 600 of some embodiments for computing the output value of a node within a machine-trained network during the training process by randomly sampling the output. The process 600 is performed by the network 430 of some embodiments and will be described in part by reference to FIG. 7 . FIG. 7 conceptually illustrates the architecture of a node 700 during training. As described above, in a typical neural network, a node includes a linear component and a non-linear component. The node 700, however, includes a linear component 705, an output sampler 710, and a non-linear component 715.

As shown, the process 600 begins by receiving (at 605) inputs for the node. As in a typical neural network, for an interior or output layer node, these inputs may be the outputs from the nodes of the previous layer (which, in some embodiments, are also calculated in the same way as the present node, using the weight distribution means and variances). FIG. 7 illustrates the node 700 receiving N inputs (from the N nodes of the previous layer) for the linear component 705.

The process 600 then performs the dot products for the linear component. The process selects (at 610) a next input. It should be understood that while the process 600 illustrates the dot product performed serially, this is a conceptual process. Some embodiments perform the multiplications of the inputs with the weight means and variances in parallel using a matrix of weight means and variances, rather than serially as shown in this FIG. 6 .

The process 600 computes (at 615) the mean and variance for the probability distribution of the selected input's weight. Though shown in this figure as an inline computation, some embodiments compute all of the categorical distribution weight means and variances before a training iteration. This enables the processor (e.g., the GPU) to store a matrix of these weight means and variances for each node and reuse this matrix for each input propagated through the network. These weight means and variances are calculated as shown in Equations (S) and (T), provided above.

Using these weight means and variances, the process 600 multiplies (at 620) the calculated mean by the input and adds this to a summed output mean calculation. Similarly, the process multiplies (at 625) the variance by the square of the input and adds this to a summed output variance calculation. The derivation of these formulas for the output mean and variance is provided by starting from the assumption that a layer computes an output matrix B by multiplying an input matrix A (with all of the inputs received from the previous layer) by a weight matrix W (i.e., B=AW). Given this, the formula for computing a particular output b_(mj) is

$\begin{matrix} {b_{mj} = {\sum\limits_{i \in I}{a_{mi}{w_{ij}.}}}} & ({HH}) \end{matrix}$ Under the assumption that the probability distributions for distinct weights are independent, then the mean for each output can be calculated as

$\begin{matrix} {{{{\mathbb{E}}\left\lbrack b_{mj} \right\rbrack} \equiv \gamma_{mj}} = {{\sum\limits_{i \in I}{a_{mi}{{\mathbb{E}}\left\lbrack w_{ij} \right\rbrack}}} = {\sum\limits_{i \in I}{a_{mi}\mu_{ij}}}}} & ({II}) \end{matrix}$ and the variance for each output calculated as

$\begin{matrix} {{{{Var}\left\lbrack b_{mj} \right\rbrack} \equiv \delta_{mj}} = {{\sum\limits_{i \in I}{a_{mi}^{2}{{Var}\left\lbrack w_{ij} \right\rbrack}}} = {\sum\limits_{i \in I}{a_{mi}^{2}{\sigma_{mi}^{2}.}}}}} & ({JJ}) \end{matrix}$ That is, the mean for an output is calculated as the sum of the products of each input multiplied by the mean for its corresponding weight, while the variance is calculated as the sum of the products of each squared input multiplied by the variance for its corresponding weight.

The process 600, which as mentioned is a conceptual process, determines (at 630) whether all of the inputs to the node are accounted for. If additional inputs require processing, the process returns to 610 to select the next input. FIG. 7 illustrates that the linear component output of the node 705 is not a single value, but rather an output mean and variance, which is provided to the output sampler 710.

Once all inputs are accounted for (and the output means and variances are computed), then the process 600 generates (at 635) a normal distribution for the node output using the calculated output mean and variance. Although the weight probability distributions are not normal (Gaussian) distributions, the central limit theorem implies (so long as the separate distributions are independent) that the output distribution can be treated as a normal distribution (assuming that there are a large number of weights per node, which is the case for a typical neural network.

The process then randomly samples (at 640) the output and stores this value for backpropagation. The randomly sampled value is used as the output of the linear component of the node. Some embodiments select a “z-score” ζ_(mj) from a zero-mean univariate normal distribution and use this to compute the output value. The output value, is therefore provided by

$\begin{matrix} {{b_{mj} = {\gamma_{mj} + \sqrt{\delta_{mj}\zeta_{mj}}}},} & ({KK}) \end{matrix}$ which isolates the randomness from the model parameters. The z-score is stored in some such embodiments for use in backpropagation, and because the randomness is isolated, the gradient computed during backpropagation does not depend on this randomness.

Randomly sampling after computation of the output means and variances rather than sampling each weight value prior to the output computation allows the processor to use of a single matrix of weight means and variances across an entire iteration of inputs, as mentioned above. Sampling each weight value prior to the dot product computation would require either the selection of the same random choice for all inputs in a training iteration (not ideal for training purposes) or a new random selection for each input (not computationally efficient for the processor). The random sampling of the output distribution is a computationally efficient technique that provides the training benefit of randomly sampling each weight for each input.

As shown in FIG. 7 , the mean and variance output of the linear component is input to an output sampler 710, which selects the z-score value for the node and outputs a single sampled output value. This value is then provided to the non-linear component 715 for the node, which may be any of the above-mentioned types of activation function. The non-linear component 715 generates the actual node output value that is provided to the next layer of the network.

For backpropagation, several derivatives are computed, owing to the different terms in the loss function and the different parameterizations of these terms. The derivatives of the negative log-likelihood term with respect to the layer outputs is computed as per normal techniques. Given these, the derivatives with respect to the layer inputs as well as the weight means and variances can be computed.

The derivatives of the node output variances with respect to each of the weight variances are provided by

$\begin{matrix} {\frac{\partial\delta_{mj}}{\partial\sigma_{ij}^{2}} = {a_{mi}^{2}.}} & ({LL}) \end{matrix}$ The derivatives of the node outputs with respect to their weight means are provided by

$\begin{matrix} {{\frac{\partial b_{mj}}{\partial\mu_{ij}} = a_{mi}},} & ({MM}) \end{matrix}$ while the derivatives of the node outputs with respect to the weight variances are provided by

$\begin{matrix} {\frac{\partial b_{mj}}{\partial\sigma_{ij}^{2}} = {{\frac{\partial b_{mj}}{\partial\delta_{mj}}\frac{\partial\delta_{mj}}{\partial\sigma_{ij}^{2}}} = {\frac{\zeta_{mj}a_{mi}^{2}}{2\sqrt{\delta_{mj}}}.}}} & ({NN}) \end{matrix}$ In addition, the derivatives of the node outputs with respect to the node output variances are provided by

$\begin{matrix} {{\frac{\partial b_{mj}}{\partial\delta_{mj}} = \frac{\zeta_{mj}}{2\sqrt{\delta_{mj}}}},} & ({OO}) \end{matrix}$ and the derivatives of the node outputs with respect to the node inputs are provided by

$\begin{matrix} {\frac{\partial b_{mj}}{\partial a_{mi}} = {\mu_{ij} + {\frac{\zeta_{mj}a_{mi}\sigma_{ij}^{2}}{\sqrt{\delta_{mj}}}.}}} & ({PP}) \end{matrix}$ Lastly, the derivatives of the negative log-likelihood with respect to any of the inputs, weight means, or weight variances, are provided by

$\begin{matrix} {{\frac{\partial\left( {- {L_{D}(q)}} \right)}{\partial\xi} = {\frac{\partial\left( {- {L_{D}(q)}} \right)}{\partial b_{mj}}\frac{\partial b_{mj}}{\partial\xi}}},{{for}\xi{any}{of}a_{mi}},{\mu_{{ij},}or{\sigma_{ij}^{2}.}}} & ({QQ}) \end{matrix}$ Some or all of these derivatives may be used during backpropagation in order to compute the gradients and update the natural parameters of the weight distributions as well as, in some embodiments, the weight spectrum values and/or the prior distribution natural parameters.

It should be noted that the description that follows assumes that the weights are not correlated (that is, that the probability distribution for one weight does not affect the probability distribution for any of the other weights). However, some embodiments do include such dependencies. For instance, image analysis networks are often convolutional neural networks that have weights organized into filters (e.g., 3×3×3 filters, that each have 27 weight values). In the case of such networks, some embodiments also include a probability whether the filter is used at all. If the filter is not used, then all weights are zero. On the other hand, if the filter is used, then the probability model discussed above applies. Furthermore, when a filter is not used (i.e., all weights are zero), this has the additional effect of providing inputs equal to zero to later nodes, and so the weights corresponding to those inputs are not meaningful.

B. Propagating Output Distributions

As mentioned above, some embodiments do not randomly sample the output at each node, and instead propagate the mean and variance (or other information about the output distributions) forward through the network. As is typical for such networks, the output value of a convolution or inner-product layer is computed as the dot product

$\begin{matrix} {{b_{mj} = {\sum\limits_{i \in l}{a_{mi}w_{ij}}}},} & ({RR}) \end{matrix}$ where a_(mi) are the inputs, w_(ij) are the weights, and b_(mj) are the outputs. When the dot product includes a large number of terms (as is typical) and the terms are uncorrelated, then the Central Limit Theorem provides that the value of the dot product can be well-approximated by a normal distribution, which enables the random sampling techniques discussed above. Under the further assumption that the random variables (weights and inputs) are uncorrelated, then the mean of the dot product is given by

$\begin{matrix} {{{\mathbb{E}}\left\lbrack b_{mj} \right\rbrack} = {\sum\limits_{i \in I}{{{\mathbb{E}}\left\lbrack a_{mi} \right\rbrack}{{\mathbb{E}}\left\lbrack w_{ij} \right\rbrack}}}} & ({SS}) \end{matrix}$ and the variance by

$\begin{matrix} {{{Var}\left\lbrack b_{mj} \right\rbrack} = {\sum\limits_{i \in I}{\left\{ {{{{Var}\left\lbrack a_{mi} \right\rbrack}{{Var}\left\lbrack w_{ij} \right\rbrack}} + {{{\mathbb{E}}\left\lbrack a_{mi} \right\rbrack}^{2}{{Var}\left\lbrack w_{ij} \right\rbrack}} + {{{Var}\left\lbrack a_{mi} \right\rbrack}{{\mathbb{E}}\left\lbrack w_{ij} \right\rbrack}^{2}}} \right\}.}}} & ({TT}) \end{matrix}$

Thus, to compute the mean and variance of the dot product output the mean and variance of the weights and layer inputs are required. Equations (S) and (T) described above in Section II.B.3 provide the weight mean and variance, respectively. For the layer input, if that input comes directly from a data layer (e.g., an input layer), then the variance is either zero or a constant determined by the precision of the data (e.g., RGB quantization). The mean and variance of a downstream input are determined based on how the mean and variance of a dot product are transformed by passing the normal distribution of dot-product values through a nonlinear activation function (e.g., a ReLU, leaky ReLU, etc.). This is described below with respect to quantized activation values and the ReLU activation function.

Performing these calculations allows the effects of weight uncertainty to be propagated forward through the network from the primary inputs to the final network outputs. In this case, the uncertainty in the output of a layer is due not only to the uncertainty in the weights of that layer but also due to the uncertainty from all the previous layers, which gives an accurate measure of the uncertainty in output values due to an overall weight uncertainty. Furthermore, the propagation of distributions rather than sampling output values reduces the variance of the estimated gradient, which on the whole leads to improved solution quality. In addition, in the case that output values are quantized, propagating distributions allows for the network to compute a continuous function of the network parameters, avoiding discontinuities and infinite gradients that would appear under the assumption that the dot products are known with infinite precision.

1. Value Quantization

In some embodiments, the network quantizes activation output values as well as weights. Value quantization appears to make the function computed by a node discontinuous, yielding a gradient that is the sum of Dirac and delta functions. However, the discontinuities occur only in the limit where the network computes values with infinite precision, which is not the case when using an approximate probabilistic knowledge of the weights.

After passing the distribution for a dot product with mean p (given by Equation (SS)) and variance σ² _(dp) (given by Equation (TT)) through a quantization layer having a quantized value spectrum v0<v ₁ < . . . <v _(n-1)  (UU) the result is a categorical distribution given by:

$\begin{matrix} {{P\left( v_{i} \right)}\left\{ {\begin{matrix} {{CD{F_{dp}\left( v_{i + 1} \right)}}\ ,} & {i = 0} \\ {{{CD{F_{dp}\left( v_{i + 1} \right)}} - {CDF_{dp}\left( v_{i} \right)}}\ ,} & {0 < i < {n_{v} - 1}} \\ {{1 - {CD{F_{dp}\left( v_{i} \right)}}}\ ,} & {i = {n_{v} - 1}} \end{matrix}.} \right.} & ({VV}) \end{matrix}$ Here CDF is the cumulative distribution function for

(μ_(dp), σ_(dp) ²): CDF _(dp)(x)=ϕ((x−μ _(dp))/σ_(dp),  (WW) where Φ is the cumulative distribution function for the standard normal distribution. While the quantized values are discrete, the probability of a quantized value P(ν_(i)) is a continuous function of the network parameters (e.g., of the natural parameters of the posterior distributions for the weights). Application of the activation function to this categorical distribution relabels the components of the categorical distribution but does not change the probabilities of the components.

When the categorical distribution for a quantized dot product is passed through an activation function ƒ(x), the result is another categorical distribution with mean

$\begin{matrix} {\mu_{act} = {\sum\limits_{0 \leq i < n_{v}}{{P\left( v_{i} \right)}{f\left( v_{i} \right)}}}} & ({XX}) \end{matrix}$ andvariance $\begin{matrix} {\sigma_{act}^{2} = {\sum\limits_{0 \leq i < n_{v}}{{P\left( v_{i} \right)}\left\lbrack {{f\left( v_{i} \right)}\  - \mu_{act}} \right\rbrack}^{2}}} & ({YY}) \end{matrix}$ With the mean and variance of each quantized activation function computed, the mean and variance for any dot product in the downstream layer can be computed using Equations (SS) and (TT). The computation time for computing the mean and variance of the quantized activation function (given the mean and variance of a dot product) is linear in the number of quantized values. This can be reduced to constant time by pretabulating pact μ_(act) and σ² _(act) as functions of μ_(dp) and σ² _(dp). The 2×2 Jacobian matrix of this transformation can also be used in backpropagation.

2. ReLU Activation Function

In many networks, the activation function outputs are not quantized. In this case, the effect of the nonlinear activation function on the dot product output mean and variance is computed. For a ReLU function (ƒ(x)=max(0, x)), these can be computed analytically. For a dot-product output y_(dp)˜N(μ_(dp),σ² _(dp)), applying a ReLU activation function results in a mean of

[ReLU(Y _(dp))]=μ_(dp)[1−ϕ(z _(o))]+σ_(dp)ϕ(z ₀)  (ZZ) where ϕ(x) is the standard normal probability density function

$\begin{matrix} {{\phi(x)} = {{\frac{1}{\sqrt{2\pi}}e^{{- x^{2}}/2}{and}z_{0}} \equiv \frac{- \mu_{dp}}{\sigma_{dp}}}} & ({AAA}) \end{matrix}$ is the z-score corresponding to y_(dp)=0, where the ReLU “turns on”. This expectation tends to 0 when μμ_(dp)<<σ_(dp) and tends to μ_(dp) when μ_(dp)>>σ_(dp). The variance of the ReLU output is

$\begin{matrix} {{{Var}\left\lbrack {ReL{U\left( Y_{dp} \right)}} \right\rbrack} = {{\left\lbrack {\sigma_{dp}^{2} + {\mu_{dp}^{2}{\phi\left( z_{0} \right)}}} \right\rbrack\left\lbrack {1 - {\phi\left( z_{0} \right)}} \right\rbrack} + {\mu_{dp}{\sigma_{dp}\left\lbrack {{2{\phi\left( z_{0} \right)}} - 1} \right\rbrack}{\phi\left( z_{0} \right)}} - {\sigma_{dp}^{2}{\phi\left( z_{0} \right)}^{2}\ }}} & ({BBB}) \end{matrix}$ which tends to 0 when μ_(dp)<<σ_(dp) and tends to σ² _(dp) when μ_(dp)>>σ_(dp). While for the ReLU the mean and variance can be computed analytically, for some activation functions this is not the case. For such other activation functions, some embodiments pre-tabulate these quantities and their derivatives, as in the case of quantized activation outputs. IV. Device with Machine-Trained Network

Once an image analysis network (e.g., for face recognition, object categorization, other image analysis, voice recognition, etc.) is trained, the network can be embedded into devices (e.g., to perform face identification, etc.) such as mobile devices, desktop computers, Internet of Things (IoT devices), etc. FIG. 8 is an example of an architecture 800 of a mobile computing device that stores neural network processing instructions, with at least one set of weight parameters for the network. Examples of mobile computing devices include smartphones, tablets, laptops, etc. As shown, the mobile computing device 800 includes one or more processing units 805, a memory interface 810 and a peripherals interface 815. While a mobile device is shown in this example, many of these principles apply to other types of devices that use neural networks. An IOT device, for instance, might have fewer subsystems and fewer types of stored instructions, to perform its specific purpose and have the ability to receive a single type of input that is evaluated with its neural network.

The peripherals interface 815 is coupled to various sensors and subsystems, including a camera subsystem 820, an audio subsystem 830, an I/O subsystem 835, and other sensors 845 (e.g., motion sensors), etc. The peripherals interface 815 enables communication between the processing units 805 and various peripherals. For example, an orientation sensor (e.g., a gyroscope) and an acceleration sensor (e.g., an accelerometer) can be coupled to the peripherals interface 815 to facilitate orientation and acceleration functions. The camera subsystem 820 is coupled to one or more optical sensors 840 (e.g., a charged coupled device (CCD) optical sensor, a complementary metal-oxide-semiconductor (CMOS) optical sensor, etc.). The camera subsystem 820 and the optical sensors 840 facilitate camera functions, such as image and/or video data capturing.

The audio subsystem 830 couples with a speaker to output audio (e.g., to output voice navigation instructions). Additionally, the audio subsystem 830 is coupled to a microphone to facilitate voice-enabled functions, such as voice recognition (e.g., for searching), digital recording, etc. The I/O subsystem 835 involves the transfer between input/output peripheral devices, such as a display, a touch screen, etc., and the data bus of the processing units 805 through the peripherals interface 815. The I/O subsystem 835 includes a touch-screen controller 855 and other input controllers 860 to facilitate the transfer between input/output peripheral devices and the data bus of the processing units 805. The touch-screen controller couples with a touch screen (not shown) to detect contact and movement on the touch screen using any of multiple touch sensitivity technologies. The other input controllers 860 are coupled to other input/control devices, such as one or more buttons.

In some embodiments, the device includes wireless communication subsystem (not shown in FIG. 8 ) to establish wireless communication functions. In some embodiments, the wireless communication subsystem includes radio frequency receivers and transmitters, and/or optical receivers and transmitters. These receivers and transmitters of some embodiments are implemented to operate over one or more communication networks such as a GSM network, a Wi-Fi network, a Bluetooth network, etc.

The memory interface 810 is coupled to memory 870. As illustrated in FIG. 8 , the memory 870 stores an operating system (OS) 872. The OS 872 includes instructions for handling basic system services and for performing hardware dependent tasks. The memory 870 also stores various sets of instructions, including (1) graphical user interface instructions 874 to facilitate graphic user interface processing; (2) image processing instructions 876 to facilitate image-related processing and functions; (3) input processing instructions 878 to facilitate input-related (e.g., touch input) processes and functions; and (4) camera instructions 884 to facilitate camera-related processes and functions. The processing units 810 execute the instructions stored in the memory 870 in some embodiments.

In addition, the memory 870 stores neural network instructions 882, for implementing a machine-trained network of some embodiments of the invention. The memory also stores at least one set of network parameters 880 (i.e., weight values for enabling the network to perform a specific purpose). These network parameters 880 may include multiple sets of weight values in some embodiments (e.g., a set of weight values for an audio-processing network and a set of weight values for an image-processing network). These sets of weights are used by the processing units 810 when executing the neural network instructions 882 to perform a specific purpose (e.g., audio processing, image processing, face recognition, etc.).

The memory 870 further stores communication instructions to facilitate communicating with one or more additional devices. The instructions described above are merely exemplary and the memory 870 includes additional and/or other instructions in some embodiments. For instance, the memory for a smartphone may include phone instructions to facilitate phone-related processes and functions. The above-identified instructions need not be implemented as separate software programs or modules. Various functions of the mobile computing device can be implemented in hardware and/or in software, including in one or more signal processing and/or application specific integrated circuits.

The memory 870 may represent multiple different storages available on the device 800. In some embodiments, the memory 870 includes volatile memory (e.g., high-speed random access memory), non-volatile memory (e.g., flash memory), a combination of volatile and non-volatile memory, and/or any other type of memory. In some embodiments, the memory 870 includes processor registers, multiple levels of processor caches (e.g., the L0 micro-operations cache, L1 instruction cache, L1 data cache, etc.), main memory (e.g., RAM), disk storage, etc. In some embodiments, when possible, one or more sets of weight parameters 880 are stored in one of the levels of processor caches, so that the data is quickly accessible and does not need to be loaded onto the processor to evaluate an input.

While the components illustrated in FIG. 8 are shown as separate components, one of ordinary skill in the art will recognize that two or more components may be integrated into one or more integrated circuits. In addition, two or more components may be coupled together by one or more communication buses or signal lines. Also, while many of the functions have been described as being performed by one component, one of ordinary skill in the art will realize that the functions described with respect to FIG. 8 may be split into two or more integrated circuits.

V. Electronic System

In this specification, the term “software” is meant to include firmware residing in read-only memory or applications stored in magnetic storage, which can be read into memory for processing by a processor. Also, in some embodiments, multiple software inventions can be implemented as sub-parts of a larger program while remaining distinct software inventions. In some embodiments, multiple software inventions can also be implemented as separate programs. Finally, any combination of separate programs that together implement a software invention described here is within the scope of the invention. In some embodiments, the software programs, when installed to operate on one or more electronic systems, define one or more specific machine implementations that execute and perform the operations of the software programs.

FIG. 9 conceptually illustrates an electronic system 900 with which some embodiments of the invention are implemented. The electronic system 900 can be used to execute any of the control, virtualization, or operating system applications described above. The electronic system 900 may be a computer (e.g., a desktop computer, personal computer, tablet computer, server computer, mainframe, a blade computer etc.), phone, PDA, or any other sort of electronic device. Such an electronic system includes various types of computer readable media and interfaces for various other types of computer readable media. Electronic system 900 includes a bus 905, processing unit(s) 910, a system memory 925, a read-only memory 930, a permanent storage device 935, input devices 940, and output devices 945.

The bus 905 collectively represents all system, peripheral, and chipset buses that communicatively connect the numerous internal devices of the electronic system 900. For instance, the bus 905 communicatively connects the processing unit(s) 910 with the read-only memory 930, the system memory 925, and the permanent storage device 935.

From these various memory units, the processing unit(s) 910 retrieves instructions to execute and data to process in order to execute the processes of the invention. The processing unit(s) may be a single processor or a multi-core processor in different embodiments, and may include generic CPUs as well as graphics processing units (GPUs).

The read-only-memory (ROM) 930 stores static data and instructions that are needed by the processing unit(s) 910 and other modules of the electronic system. The permanent storage device 935, on the other hand, is a read-and-write memory device. This device is a non-volatile memory unit that stores instructions and data even when the electronic system 900 is off. Some embodiments of the invention use a mass-storage device (such as a magnetic or optical disk and its corresponding disk drive) as the permanent storage device 935.

Other embodiments use a removable storage device (such as a floppy disk, flash drive, etc.) as the permanent storage device. Like the permanent storage device 935, the system memory 925 is a read-and-write memory device. However, unlike storage device 935, the system memory is a volatile read-and-write memory, such a random-access memory. The system memory stores some of the instructions and data that the processor needs at runtime. In some embodiments, the invention's processes are stored in the system memory 925, the permanent storage device 935, and/or the read-only memory 930. From these various memory units, the processing unit(s) 910 retrieves instructions to execute and data to process in order to execute the processes of some embodiments.

The bus 905 also connects to the input and output devices 940 and 945. The input devices enable the user to communicate information and select commands to the electronic system. The input devices 940 include alphanumeric keyboards and pointing devices (also called “cursor control devices”). The output devices 945 display images generated by the electronic system. The output devices include printers and display devices, such as cathode ray tubes (CRT) or liquid crystal displays (LCD). Some embodiments include devices such as a touchscreen that function as both input and output devices.

Finally, as shown in FIG. 9 , bus 905 also couples electronic system 900 to a network 965 through a network adapter (not shown). In this manner, the computer can be a part of a network of computers (such as a local area network (“LAN”), a wide area network (“WAN”), or an Intranet, or a network of networks, such as the Internet. Any or all components of electronic system 900 may be used in conjunction with the invention.

Some embodiments include electronic components, such as microprocessors, storage and memory that store computer program instructions in a machine-readable or computer-readable medium (alternatively referred to as computer-readable storage media, machine-readable media, or machine-readable storage media). Some examples of such computer-readable media include RAM, ROM, read-only compact discs (CD-ROM), recordable compact discs (CD-R), rewritable compact discs (CD-RW), read-only digital versatile discs (e.g., DVD-ROM, dual-layer DVD-ROM), a variety of recordable/rewritable DVDs (e.g., DVD-RAM, DVD-RW, DVD+RW, etc.), flash memory (e.g., SD cards, mini-SD cards, micro-SD cards, etc.), magnetic and/or solid state hard drives, read-only and recordable Blu-Ray® discs, ultra-density optical discs, any other optical or magnetic media, and floppy disks. The computer-readable media may store a computer program that is executable by at least one processing unit and includes sets of instructions for performing various operations. Examples of computer programs or computer code include machine code, such as is produced by a compiler, and files including higher-level code that are executed by a computer, an electronic component, or a microprocessor using an interpreter.

While the above discussion primarily refers to microprocessor or multi-core processors that execute software, some embodiments are performed by one or more integrated circuits, such as application specific integrated circuits (ASICs) or field programmable gate arrays (FPGAs). In some embodiments, such integrated circuits execute instructions that are stored on the circuit itself.

As used in this specification, the terms “computer”, “server”, “processor”, and “memory” all refer to electronic or other technological devices. These terms exclude people or groups of people. For the purposes of the specification, the terms display or displaying means displaying on an electronic device. As used in this specification, the terms “computer readable medium,” “computer readable media,” and “machine readable medium” are entirely restricted to tangible, physical objects that store information in a form that is readable by a computer. These terms exclude any wireless signals, wired download signals, and any other ephemeral signals.

While the invention has been described with reference to numerous specific details, one of ordinary skill in the art will recognize that the invention can be embodied in other specific forms without departing from the spirit of the invention. In addition, some of the figures (including FIGS. 5 and 6 ) conceptually illustrate processes. The specific operations of these processes may not be performed in the exact order shown and described. The specific operations may not be performed in one continuous series of operations, and different specific operations may be performed in different embodiments. Furthermore, the process could be implemented using several sub-processes, or as part of a larger macro process. Thus, one of ordinary skill in the art would understand that the invention is not to be limited by the foregoing illustrative details, but rather is to be defined by the appended claims. 

We claim:
 1. A method for training a machine-trained (MT) network, the method comprising: propagating a plurality of inputs through the MT network to generate an output for each of the inputs, wherein (i) each of the inputs is associated with an expected output, (ii) the MT network uses a plurality of network parameters to process the inputs, and (iii) each network parameter of a set of the network parameters is defined during training as a probability distribution across a ternary set of possible values for the network parameter, the ternary set of possible values for each network parameter comprising the value zero, a positive value for the network parameter, and a negation of the positive value for the network parameter; calculating a value of a loss function for the MT network comprising (i) a first term that measures network error based on the expected outputs compared to the generated outputs and (ii) a second term that penalizes divergence of the probability distribution for each network parameter in the set of network parameters from a predefined probability distribution for the network parameter, wherein the predefined probability distribution for each of the network parameters comprises a probability value for each of the possible values for the network parameter, wherein the largest probability value for each network parameter is the probability value for the value zero; and using the calculated loss function value to train the network parameters, wherein the second term of the loss function and the predefined probability distributions having the largest probability value for the value zero results in a majority of the network parameters being trained to have a value of zero, wherein for each network parameter, the second term increases as the probability values for the positive value for the network parameter and the negation of the positive value for the network parameter in the probability distribution for the network parameter increase.
 2. The method of claim 1, wherein using the calculated loss function value to train the network parameters comprises: backpropagating the calculated loss function value through the MT network to determine, for each of at least a subset of the network parameters, a rate of change in the calculated loss function value relative to a rate of change in the network parameter; and modifying the probability distribution for each network parameter in the subset according to the determined rate of change for the network parameter.
 3. The method of claim 1, wherein the machine-trained network is for embedding into a device to perform a specific function.
 4. The method of claim 1, wherein the ternary set of possible values for each of at least a subset of the network parameters comprises zero, one, and negative one.
 5. The method of claim 1, wherein the predefined probability distribution for each of at least a subset of the network parameters comprises a categorical distribution.
 6. The method of claim 1, wherein the predefined probability distribution for each of the network parameters of the set comprises a probability value of at least 50% for the value zero.
 7. The method of claim 1, wherein for each network parameter of at least a particular subset of the network parameters, the first term decreases as the probability values for the positive value for the network parameter and the negation of the positive value for the network parameter in the probability distribution of the network parameter increase.
 8. The method of claim 1, wherein the machine-trained network comprises input nodes, output nodes, and interior nodes between the input nodes and output nodes, wherein each node produces an output value and each interior node and output node receives as input values a set of output values of other nodes and applies weights to each received input value, wherein the set of network parameters comprises the weights.
 9. The method of claim 8, wherein propagating a particular input through the MT network comprises, for a particular node: determining an output value probability distribution for the node by (i) calculating a mean output value based on the input values and means of the probability distributions for the weights of the node and (ii) calculating a variance of the output value based on the input values and variances of the weights for the node; and randomly sampling the output value probability distribution to determine the output value for the particular node.
 10. The method of claim 9, wherein the probability distributions for the weights are not normal distributions, wherein the output value probability distribution is treated as a normal distribution.
 11. The method of claim 8, wherein propagating a particular input through the MT network comprises, for a particular node: receiving means and variances of output probability distributions for a set of previous nodes as the input values for the particular node; determining an output probability distribution for a linear function of the node by (i) calculating a mean output value based on the received means of the probability distributions of the set of previous nodes and means of the probability distributions for the weights of the node and (ii) calculating a variance of the output value based on the received means and variances of the probability distributions of the set of previous nodes and means and variances of the weights for the node; and determining an output probability distribution for a nonlinear activation function of the node based on the calculated mean and variance for the linear function of the node.
 12. A non-transitory machine-readable medium storing a program which when executed by at least one processing unit trains a machine-trained (MT) network, the program comprising sets of instructions for: propagating a plurality of inputs through the MT network to generate an output for each of the inputs, wherein (i) each of the inputs is associated with an expected output, (ii) the MT network uses a plurality of network parameters to process the inputs, and (iii) each network parameter of a set of the network parameters is defined during training as a probability distribution across a ternary set of possible values for the network parameter, the ternary set of possible values for each network parameter comprising the value zero, a positive value for the network parameter, and a negation of the positive value for the network parameter; calculating a value of a loss function for the MT network comprising (i) a first term that measures network error based on the expected outputs compared to the generated outputs and (ii) a second term that penalizes divergence of the probability distribution for each network parameter in the set of network parameters from a predefined probability distribution for the network parameter, wherein the predefined probability distribution for each of the network parameters comprises a probability value for each possible values for the network parameter, wherein the largest probability value for each network parameter is the probability value for the value zero; and using the calculated loss function value to train the network parameters, wherein the second term of the loss function and the predefined probability distributions having the largest probability value for the value zero results in a majority of the network parameters being trained to have a value of zero, wherein for each network parameter, the second term increases as the probability values for the positive value for the network parameter and the negation of the positive value for the network parameter in the probability distribution for the network parameter increase, wherein for each network parameter of at least a particular subset of the network parameters, the first term decreases as the probability values for the positive value for the network parameter and the negation of the positive value for the network parameter in the probability distribution of the network parameter increase.
 13. The non-transitory machine-readable medium of claim 12, wherein the ternary set of possible values for each of the network parameters of the set of network parameters comprises zero, one, and negative one.
 14. The non-transitory machine-readable medium of claim 12, wherein the machine-trained network comprises input nodes, output nodes, and interior nodes between the input nodes and output nodes, wherein each node produces an output value and each interior node and output node receives as input values a set of output values of other nodes and applies weights to each received input value, wherein the set of network parameters comprises the weights.
 15. The non-transitory machine-readable medium of claim 14, wherein the set of instructions for propagating a particular input through the MT network comprises sets of instructions for: for a particular node: determining an output value probability distribution for the node by (i) calculating a mean output value based on the input values and means of the probability distributions for the weights of the node and (ii) calculating a variance of the output value based on the input values and variances of the weights for the node; and randomly sampling the output value probability distribution to determine the output value for the particular node.
 16. The non-transitory machine-readable medium of claim 14, wherein the set of instructions for propagating a particular input through the MT network comprises sets of instructions for: for a particular node: receiving means and variances of output probability distributions for a set of previous nodes as the input values for the particular node; determining an output probability distribution for a linear function of the node by (i) calculating a mean output value based on the received means of the probability distributions of the set of previous nodes and means of the probability distributions for the weights of the node and (ii) calculating a variance of the output value based on the received means and variances of the probability distributions of the set of previous nodes and means and variances of the weights for the node; and determining an output probability distribution for a nonlinear activation function of the node based on the calculated mean and variances for the linear function of the node.
 17. The non-transitory machine-readable medium of claim 15, wherein the probability distributions for the weights are not normal distributions, wherein the output value probability distribution is treated as a normal distribution. 